package com.example.Mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.example.pojo.Gongyingshang;
import com.example.pojo.Materialzhu;
import com.example.pojo.inquiry;
import com.example.pojo.inquirycong;
import com.example.vo.cgxjvo;
import com.example.vo.gysvo;

public interface cgxjdao {
	
	//查询主表（分页1）
	public List<inquiry> querybypage(@Param("0")int pagenum,@Param("1")int pagesize);
	
	//通过id查询
	public int querybyid(@Param("billno")String id);
	
	//查询数量
	public int querycount();
	
	//查询询价表的历史交易信息
	@Select("select ping.trantype,ping.fromno,zha.billdate,zha.currid,zha.exchrate, "
			+ "wl.ProdId,wl.Prodsize,wl.ProdName,wl.danwei,ping.squantity,ping.discount, "
			+ "zha.Priceoftax,ping.oldprice,ping.sPrice,ping.amount from inquiry zha " 
			+ "right join inquirycong ping "
			+ "join materialzhu wl on "
			+ "ping.ProdId=wl.ProdId "
			+ "on zha.billno=ping.billno " 
			+ "where zha.Customerid=#{customerid} ")
	public List<cgxjvo> queryhistory(@Param("customerid")String customerid);
	
	
	//查询订单的历史交易信息
	@Select("select ping.trantype,ping.fromno,zha.billdate,zha.currid,zha.exchrate, "
			+ "wl.ProdId,wl.Prodsize,wl.ProdName,wl.danwei,ping.squantity,ping.discount, "
			+ "zha.Priceoftax,ping.oldprice,ping.sPrice,ping.amount from oderfrom zha " 
			+ "right join oderfromcong ping "
			+ "join materialzhu wl on "
			+ "ping.ProdId=wl.ProdId "
			+ "on zha.billno=ping.billno " 
			+ "where zha.Customerid=#{customerid} ")
	public List<cgxjvo> queryhistory1(@Param("customerid")String customerid);
	
	//查询入库单的历史交易信息
		@Select("select ping.Danbie as trantype,ping.BillNO as fromno,zha.billdate,zha.currid,zha.exchrate, "
		+"wl.ProdId,wl.Prodsize,wl.ProdName,wl.danwei,ping.Shuliang as squantity,ping.zheshu as discount, "
		+"zha.Priceoftax,ping.Zhikoudanjia as oldprice,ping.price as sPrice,ping.Jine as amount from belaidup zha "
		+"right join belaidupcong ping "
		+"join materialzhu wl on "
		+"ping.ProdId=wl.ProdId "
		+"on zha.billno=ping.Pk_id "	 
		+"where zha.CustID=#{customerid} ")
	public List<cgxjvo>  queryhistory2(@Param("customerid")String customerid);
	
	//查询所有的物料信息 
	@Select("select * from materialzhu")
	public List<Materialzhu> querywl();
	
	//通过id查询所有的物料信息 
	@Select("select * from materialzhu where prodId=#{prodId}")
	public List<Materialzhu> querywlbyid(@Param("prodId")String prodId);
	 
	//查询所有的供应商信息
	@Select("select * from gongyingshang")
	public List<Gongyingshang> querygys();
	
	//通过id查询所有的供应商信息
	@Select("select g.GYSid,g.GYSname,g.personnelid,p.personnelname,p.deptid,d.deptname from gongyingshang g inner join "
	+ "Personnel p on g.personnelid=p.personnelid inner join Dept d on d.deptid=p.deptid where g.GYSid=#{GYSid}")
	public gysvo querygysbyid(@Param("GYSid")String GYSid);
	
	//新增主表
	public void addxj(inquiry in);
	
	//新增从表
	public void addxj1(inquiry in);
	
	//修改审核状态
	public void updateshzt(@Param("billno")String id);
	
	//修改反审核状态
	public void updateshzt1(@Param("billno")String id);
	
	//删除询价主表
	public void deletexj(String billno);
	
	//删除从表
	public void deletexjcong(String billno);
}
